<?php

namespace apiend\modules\passport\controllers;

use Yii;
use apiend\components\Controller;
use apiend\modules\passport\models\BindMobileForm;

/**
 * 帐号绑定信息
 * @author emhome <emhome@163.com>
 * @since 2.0
 */
class BindController extends Controller {

    /**
     * @inheritdoc
     */
    protected function verbs() {
        return [
            '*' => ['POST'],
        ];
    }

    /**
     * @inheritdoc
     */
    protected function rules() {
        return [
            [
                'allow' => true,
                'roles' => ['@'],
            ],
        ];
    }

    /**
     * 绑定手机号
     * @return mixed
     */
    public function actionMobile() {
        $model = new BindMobileForm();
        if (!$model->load(Yii::$app->request->post(), '')) {
            parent::error('请输入短信验证码');
        }
        $model->user_id = $this->uid;
        return $model->check();
    }

    /**
     * 绑定微信
     * @return mixed
     */
    public function actionWechat() {
        $model = new CaptchaValidateForm();
        if (!$model->load(Yii::$app->request->post(), '')) {
            parent::error('请输入短信验证码');
        }
        $model->user_id = $this->uid;
        return $model->check();
    }

    /**
     * 绑定QQ号
     * @return mixed
     */
    public function actionQq() {
        $model = new CaptchaValidateForm();
        if (!$model->load(Yii::$app->request->post(), '')) {
            parent::error('请输入短信验证码');
        }
        $model->user_id = $this->uid;
        return $model->check();
    }

    /**
     * 绑定微博
     * @return mixed
     */
    public function actionWeibo() {
        $model = new CaptchaValidateForm();
        if (!$model->load(Yii::$app->request->post(), '')) {
            parent::error('请输入短信验证码');
        }
        $model->user_id = $this->uid;
        return $model->check();
    }

}
